package samber

import (
	"fmt"
	"github.com/samber/lo"
)

// KeyBy 根据数组的自己逻辑组建Map
func KeyBy() {
	list := []string{"a", "aa", "aaa"}
	result := lo.KeyBy[int, string](list, func(str string) int {
		return len(str)
	})
	fmt.Printf("%v\n", result) // map[1:a 2:aa 3:aaa]
}

// Keys 获取Map的Key
func Keys() {
	kv := map[string]int{"foo": 1, "bar": 2}
	result := lo.Keys(kv)
	fmt.Printf("%v\n", result) // [foo bar]
}
